//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package commands;

import common.ByteStream;

public class BuyObject extends LogicCommand {
   final int cmdId = 4;
   final int buyType;
   final int objectId;
   final int X;
   final int Y;
   final boolean mirrored;

   public BuyObject(int tt, int treeId, int X, int Y, boolean mirrored) {
      super(tt);
      this.objectId = treeId;
      this.X = X << 9;
      this.Y = Y << 9;
      this.mirrored = mirrored;
      this.buyType = -1;
   }

   public BuyObject(int tt, int resultId, int prevId, int X, int Y, boolean mirrored) {
      super(tt);
      this.objectId = resultId;
      this.buyType = prevId;
      this.X = X << 9;
      this.Y = Y << 9;
      this.mirrored = mirrored;
   }

   public int getCommandId() {
      return 4;
   }

   public void encode(ByteStream stream) {
      stream.writeInt(4);
      stream.writeInt(this.objectId);
      stream.writeInt(this.buyType);
      stream.writeInt(this.X);
      stream.writeInt(this.Y);
      stream.writeBoolean(this.mirrored);
      stream.writeInt(this.ticksWhenTouch().intValue());
   }
}
